package your_car_status

class Vehicle {

    String licensePlate     //Placa de vehiculo
    String confirmLicensePlate     //Placa de vehiculo
    String carModel
    String colour           //Numero de serie
    String serialNumber     //Numero de poliza
    String policyNumber      //automobile, minibus, etc.
    String type             //Marca del vehiculo
    String carMake          //Numero de cilindros
    String cylinderNumber   //kilometraje
    String mileage              //Tipo de combustible
    String fuelType
    
    static belongsTo = [customer : Customer]
    static hasMany=[ diagnostic:Diagnostic, inventory:Inventory, services:Services]
    static constraints = {
        licensePlate ( unique: true, blank: false, matches: "[A-Z][A-Z][A-Z][ ][0-9][0-9][0-9]",  validator: {licensePlate, obj ->
         def confirmLicensePlate = obj.properties['confirmLicensePlate']
         if(confirmLicensePlate == null) return true 
         if (confirmLicensePlate == licensePlate)return true 
         else return['invalid.error']
     })
        confirmLicensePlate unique: true, blank: false, matches: "[A-Z][A-Z][A-Z][ ][0-9][0-9][0-9]"
        colour blank : false , matches: "[a-zA-Z-0-9]+"
        serialNumber unique: true, blank: false, size: 10..17, matches: "[0-9]+"
        policyNumber unique: true, blank: false, size: 10..17, matches: "[0-9]+"
        cylinderNumber blank:false, matches: "[0-9]+"
        mileage blank: false
        fuelType blank: false
    }
}
